package com.ruoyi.system.service.impl;

import com.ruoyi.system.domain.Livebroadcastingroom;
import com.ruoyi.system.domain.StudioAttention;
import com.ruoyi.system.domain.txim.TLSSigAPIv2;
import com.ruoyi.system.mapper.*;
import com.ruoyi.system.service.ILiveModularService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 直播间信息Service业务层处理
 * 
 * @author kinglu
 * @date 2021-11-30
 */
@Service
public class LiveModularServiceImpl implements ILiveModularService
{
    @Value("${IMConfig.sdkAppId}")
    private long sdkAppId;

    @Value("${IMConfig.secretKey}")
    private String secretKey;

    private long expire=60*60*24*7;

    @Autowired
    private LiveModularMapper liveModularMapper;

    /**
     * 查询直播间信息
     * 
     * @param roomId 直播间信息主键
     * @return 直播间信息
     */
    @Override
    public Livebroadcastingroom selectLivebroadcastingroomByRoomId(Long roomId)
    {
        return liveModularMapper.selectLivebroadcastingroomByRoomId(roomId);
    }

    /**
     * 查询用户关注直播间
     *
     * @param userId 用户编号
     * @return 直播间信息
     */
    public List<StudioAttention> selectStudioAttentionList(Long userId){
        return liveModularMapper.selectStudioAttentionList(userId);
    }

    @Override
    public String generateUserSig(String userid) {
        TLSSigAPIv2 tlsSigAPIv2 = new TLSSigAPIv2(sdkAppId,secretKey);
        return tlsSigAPIv2.genUserSig(userid,expire);
    }
}
